{extend name="public/base"/}
{block name="body"}
<div class="main-box no-header clearfix">
	<header class="main-box-header clearfix">
		<div class="pull-left">
			<h2>{$meta_title}</h2>
		</div>
		<div class="pull-right">
			<a href="{:url('add')}" class="btn btn-primary "> <i class="fa fa-plus-circle fa-lg"></i> 新增</a>
			<button class="btn btn-danger ajax-post confirm" url="{:url('del')}" target-form="ids">删 除</button>
			<button class="btn btn-success list_sort" url="{:url('sort','','')}">排序</button>
		</div>
	</header>
	<div class="main-box-body clearfix">
		<div class="table-responsive">
      <table class="table table-striped table-hover">
        <thead>
          <tr>
            <th width="30"><input class="checkbox check-all" type="checkbox"></th>
            <th width="60">ID</th>
            <th>分类名称</th>
            <th>排序</th>
            <th>状态</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
          {volist name="list" id="item"}
          <tr>
            <td><input class="ids row-selected" type="checkbox" name="id[]" value="{$item['id']}"></td>
            <td>{$item['id']}</td>
            <td>{$item['cat_name']}</td>
            <td>{$item['sort']}</td>
            <td>
              {if condition="$item['status'] eq '0'"}
              <span class="label label-danger">禁用</span>
              {elseif condition="$item['status'] eq '1'"/}
              <span class="label label-primary">启用</span>
              {/if}
            </td>
            <td>
              <a href="{:url('edit',array('id'=>$item['id']))}">编辑</a>
              <a href="{:url('del',array('id'=>$item['id']))}" class="confirm ajax-get">删除</a>
            </td>
          </tr>
          {/volist}
        </tbody>
      </table>

		</div>
	</div>
</div>
{/block}

{block name="script"}
<script type="text/javascript" src="__PUBLIC__/js/bootstrap-editable.min.js"></script>
<script type="text/javascript">
$(function() {
	//点击排序
	$('.list_sort').click(function(){
		var url = $(this).attr('url');
		var ids = $('.ids:checked');
		var param = '';
		if(ids.length > 0){
			var str = new Array();
			ids.each(function(){
				str.push($(this).val());
			});
			param = str.join(',');
		}

		if(url != undefined && url != ''){
			window.location.href = url + '/ids/' + param;
		}
	});

});
</script>
{/block}

